
import java.io.PrintWriter;
import java.util.HashMap;

class WhileStatement extends Statement {

	private Node exp_;
	private Node stat_list_;

	public WhileStatement(Node e, Node ss) {
		exp_ = e;
		stat_list_ = ss;
	}

	@Override
	public void print(PrintWriter pw) {
		pw.println("Node name : WhileStatement");
		// assert( exp_ && stat_list_);
		exp_.print(pw);
		if (stat_list_ != null) {
			stat_list_.print(pw);
		}
	}

	@Override
	public String translate(HashMap<String, PrintWriter> pws, String condition, SymbolTable st,
			String parent) {
		String key = st.getStack().get(1);
		PrintWriter pw = pws.get(key);
		printIndent(pw, st.getLevel());
		st.getStack().push("while");
		
		pw.print("while(");
		exp_.translate(pws,null,st,null);
		pw.print(") ");
		stat_list_.translate(pws,null,st,null);
		return null;
		
	}

}